<script setup lang="ts">
import { instance } from '@/utils/request'
import { ElNotification } from 'element-plus'
import { ref } from 'vue'

const contorlFormData = ref({
  id: 6,
  code: 1,
})

const contorlFormSubmit = async () => {
  await instance({
    url: `/remote/v1/device`,
    method: 'get',
    params: contorlFormData.value,
  })
  ElNotification({ title: '发送成功', type: 'success' })
}

const modeFormData = ref({
  id: 6,
  code: 1,
})

const modeFormSubmit = async () => {
  await instance({
    url: `/remote/v1/lift`,
    method: 'get',
    params: modeFormData.value,
  })
  ElNotification({ title: '发送成功', type: 'success' })
}
</script>

<template>
  <ElDialog title="升降台手动控制" width="320" align-center draggable destroy-on-close :modal="false">
    <div class="flex flex-col gap-4">
      <div class="text-17px">模式切换</div>
      <ElForm :model="modeFormData" label-width="80px">
        <ElFormItem label="控制设备">
          <ElSelect v-model="modeFormData.id">
            <ElOption label="升降台1" :value="6"></ElOption>
            <ElOption label="升降台2" :value="8"></ElOption>
          </ElSelect>
        </ElFormItem>
        <ElFormItem label="控制指令">
          <ElSelect v-model="modeFormData.code">
            <ElOption label="机台停止" :value="1"></ElOption>
            <ElOption label="机台复位" :value="2"></ElOption>
            <ElOption label="手动模式" :value="3"></ElOption>
            <ElOption label="自动模式" :value="4"></ElOption>
          </ElSelect>
        </ElFormItem>
        <ElFormItem>
          <ElButton @click="modeFormSubmit">提交</ElButton>
        </ElFormItem>
      </ElForm>
      <div class="text-17px">指令发送</div>
      <ElForm :model="contorlFormData" label-width="80px">
        <ElFormItem label="控制设备">
          <ElSelect v-model="contorlFormData.id">
            <ElOption label="升降台1" :value="6"></ElOption>
            <ElOption label="升降台2" :value="8"></ElOption>
            <ElOption label="清洗架" :value="4"></ElOption>
          </ElSelect>
        </ElFormItem>
        <ElFormItem label="控制指令">
          <ElSelect v-model="contorlFormData.code">
            <ElOption label="升降 Z 轴到安全位" :value="1"></ElOption>
            <ElOption label="升降 Z 轴到 CCD 拍照位" :value="2"></ElOption>
            <ElOption label="升降 Z 轴到取罐位" :value="3"></ElOption>
            <ElOption label="夹紧 X 轴到安全位" :value="17"></ElOption>
            <ElOption label="夹紧 X 轴到 CCD 拍照位" :value="18"></ElOption>
            <ElOption label="夹紧 X 轴到取罐位" :value="19"></ElOption>
            <ElOption label="AGV 平台轴到打开位" :value="33"></ElOption>
            <ElOption label="AGV 平台轴到关闭位" :value="34"></ElOption>
            <ElOption label="清洗区气缸松开" :value="49"></ElOption>
            <ElOption label="清洗区气缸夹紧" :value="50"></ElOption>
          </ElSelect>
        </ElFormItem>
        <ElFormItem>
          <ElButton @click="contorlFormSubmit">提交</ElButton>
        </ElFormItem>
      </ElForm>
    </div>
  </ElDialog>
</template>
